package com.itheima.Test;

import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;

public class Test001 {
    public static void main(String[] args) {
        /*
        十、已知数组存放一批QQ号码，QQ号码最长为11位，
        最短为5位String[] strs = {"12345","67891","12347809933","98765432102","67891","12347809933"}。
        将该数组里面的所有qq号都存放在LinkedList中，
        将list中重复元素删除，将list中所有元素分别用迭代器和增强for循环打印出来。
         */
        String[] strs = {"12345","67891","12347809933","98765432102","67891","12347809933"};
        LinkedList<String> list = new LinkedList<>();
        for (String str : strs) {
            list.add(str);
        }
        //创建一个hashset集合;
        HashSet<String> set = new HashSet<>();
        for (String s : list) {
            set.add(s);
        }
        list.clear();
        for (String s : set) {
            list.add(s);
        }
        System.out.println(list);


        //使用迭代器遍历;
        Iterator<String> iterator = list.iterator();
        while (iterator.hasNext()) {
            String s = iterator.next();
            System.out.println(s);
        }


    }
}
